package com.baizhi.action;

import com.baizhi.entity.Title;
import com.baizhi.service.TitleService;
import com.baizhi.service.TitleServiceImpl;


import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.util.List;

public class UserMainAction extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");
        resp.setCharacterEncoding("utf-8");


        HttpSession session = req.getSession();
        TitleService ts = new TitleServiceImpl();
        List<Title> titles = ts.showAll();
        req.setAttribute("titles",titles);
        session.setAttribute("titles",titles);






        req.getRequestDispatcher("/blog.jsp").forward(req,resp);
    }
}
